package com.example.zjm.fragmentdome;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class Fragment01 extends Fragment {
    private ListView lv_name;
    private List<String> names;
    private ArrayAdapter<String> arrayAdapter;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment01,null);
        names = new ArrayList<>();
        names.add("张飞");
        names.add("赵云");
        names.add("黄忠");
        names.add("关羽");
        names.add("马超");

        lv_name =view.findViewById(R.id.lv_test);
        arrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.lv_item, names);
        lv_name.setAdapter(arrayAdapter);
        return view;
    }
}
